package org.juc.stream;

import java.util.function.Supplier;

public class SupplyDemo {
    public static void main(String[] args) {
        // 接口匿名实现类实现
        // anonymousInterface();
        // 使用JDK内置自带的供给型接口
        SupplierInterface();
    }

    private static void SupplierInterface() {
        Supplier<Integer> integerSupplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                return 1024;
            }
        };
        System.out.println(integerSupplier.get());
    }

    private static void anonymousInterface() {
        TestSupply testSupply = new TestSupply() {

            @Override
            public Integer get() {
                return 1024;
            }
        };
        System.out.println(testSupply.get());
    }
}

/**
 * 测试供应(无传入型参数 有返回值)
 *
 * @author Admin
 * @date 2021/11/30
 */
interface TestSupply{
    Integer get();
}
